﻿Imports System.Data

Partial Class Controls_ConfirmOrderGrid
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim dec As Decimal
        Dim ProductsTA As New LogginsLogDSTableAdapters.usp_ShowCreditsByEntityTableAdapter()
        Dim ProductsDT As LogginsLogDS.usp_ShowCreditsByEntityDataTable
        Dim VirtualProductsDT As DataTable = GetTable()
        If Not Session("SelectedEntityID") Is Nothing Then
            Dim x As Integer = Session("SelectedEntityID")
            ProductsDT = ProductsTA.GetData(x, dec)

            If Not Session("BuyDT") Is Nothing Then
            End If

            Dim table As DataTable = CType(Session("BuyDT"), DataTable)
            For Each dRow As DataRow In table.Rows
                For Each ProductsRow As LogginsLogDS.usp_ShowCreditsByEntityRow In ProductsDT
                    If ProductsRow.ItemId = dRow("ItemId").ToString() Then
                        VirtualProductsDT.Rows.Add(ProductsRow.ItemId, ProductsRow.Name, ProductsRow.Units, ProductsRow.Price)

                    End If

                    'Dim resultbyitmid = (From p In ProductsDT.AsEnumerable() Where p.ItemId =  Select p).FirstOrDefault()
                Next
            Next

            GridView1.DataSource = VirtualProductsDT
            GridView1.DataBind()
            Session("VirtualProductsDT") = VirtualProductsDT

        End If


    End Sub


    Function GetTable() As DataTable
        ' Create new DataTable instance.Where p.ItemId = dRow("ItemId").ToString()
        Dim table As New DataTable
        ' Create four typed columns in the DataTable.
        table.Columns.Add("ItemId", GetType(Integer))
        table.Columns.Add("Name", GetType(String))
        table.Columns.Add("Units", GetType(String))
        table.Columns.Add("Price", GetType(String))
        ' Add five rows with those columns filled in the DataTable.
        'table.Rows.Add(25, "Indocin", "David", DateTime.Now)
        'table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now)
        'table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now)
        'table.Rows.Add(21, "Combivent", "Janet", DateTime.Now)
        'table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now)
        Return table
    End Function
End Class
